<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="dgg" uri="/dgg-tags" %>
<div class="body-main">
    <table style="width: 100%;">
        <tbody>
        <tr>
            <td colspan="2">
            <div class="table-warp">
                <c:if test="${fn:length(orderList) > 1}">
                    <table class="cell-border crm-table columnsHidden dataTable" id="orderTable">
                        <tr style="text-align: center">
                            <td><b>序号</b></td>
                            <td><b>生产单编号</b></td>
                            <td><b>合同编号</b></td>
                            <td><b>操作</b></td>
                        </tr>
                        <c:forEach items="${orderList}" var="order" varStatus="status">
                            <tr style="text-align: center">
                                <td>${status.index + 1}</td>
                                <td>${order.scProductOrderNo}<input name="subOrderIds" type="hidden" value="${order.id}" /></td>
                                <td>${order.contractNo}</td>
                                <td>
                                    <a href="JavaScript:void(0);" class="layui-btn layui-btn-orange"
                                       onclick="removeOrder(this)">剔除</a>
                                </td>
                            </tr>
                        </c:forEach>
                    </table>
                </c:if>
            </div>
            </td>
        </tr>
        <tr>
            <th style="width: 80px"><span class="required">备注:</span></th>
            <td>
                <textarea class="textarea-style" id="remark" name="remark" rows="3" placeholder="500字以内"></textarea>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        areaLength($('#remark'),500)
    });

    function removeOrder(obj) {
        var num = $("#orderTable").children().children("tr").length;
        if(num == 2){
            DGG.Errors("请至少保留一个订单!");
            return;
        }
        $(obj).parent().parent().remove();
    }
</script>
